package cmath.cmath;

import com.server.order.orderImpl;
import com.server.runtime.vehicleImpl;

import combat.protocol.data.DoublePoint;

public class Position {
	
	private static DoublePoint _nextposition;
	private static double _vectorsnelheid;
	private static double _newangle;
	
	
	public static DoublePoint GetNextPosition(vehicleImpl _object, orderImpl _order)
	{
		_nextposition = new DoublePoint(0,0);
		_vectorsnelheid = (_object.getSpeed() / 1000) * 5;
		
		_newangle = GetNewDirection(_object, _order);
		
		_nextposition.setX(_object.getPosition().getX() + _vectorsnelheid * Math.cos(Math.toRadians(_newangle)));
		_nextposition.setY(_object.getPosition().getY() + _vectorsnelheid * Math.sin(Math.toRadians(_newangle)));
				
		return _nextposition;
	}
	
	public static double GetNewDirection(vehicleImpl _object, orderImpl _order)
	{
		
		//if(_object.getorder != _order)
			//rotationaldirection
		
		
		//_newangle = _object.getDirection() + (RenderPanel.rotDirection * (Angle.CalculateTurnAngle(Angle.CalculateAngleDiff(_object, Angle.Calculate(_object, _order)))));
		_newangle = _object.getDirection() + (RotationalDirection.Calculate(_object, _order)) * (Angle.CalculateTurnAngle(Angle.CalculateAngleDiff(_object, Angle.Calculate(_object, _order))));
		_newangle = Angle.To360Scale(_newangle);
		
		return _newangle;
		
	}

	
}
